package com.itfitness.openglcamera.widget

import android.content.Context
import android.opengl.GLSurfaceView
import android.util.AttributeSet
import android.view.SurfaceHolder
import com.itfitness.openglcamera.render.GLRender
import java.util.jar.Attributes

/**
 *
 * @ProjectName:    OpenGLCamera
 * @Package:        com.itfitness.openglcamera.widget
 * @ClassName:      CameraView
 * @Description:     java类作用描述
 * @Author:         itfitness
 * @CreateDate:     2022-12-04 15:57
 * @UpdateUser:     更新者：
 * @UpdateDate:     2022-12-04 15:57
 * @UpdateRemark:   更新说明：
 */
class CameraView:GLSurfaceView {
    private val glRender: GLRender
    constructor(cotext:Context):this(cotext,null)
    constructor(cotext:Context,attr: AttributeSet?):super(cotext,attr){
        setEGLContextClientVersion(3)
        glRender = GLRender(this)
        setRenderer(glRender)
        //不让OpenGL自动渲染
        renderMode = GLSurfaceView.RENDERMODE_CONTINUOUSLY
    }

    override fun surfaceDestroyed(holder: SurfaceHolder) {
        super.surfaceDestroyed(holder)
        //释放资源
        glRender.ndkRelease()
    }

}